package com.ruoyi.web.controller.huiyuan;

import java.util.List;

import com.ruoyi.system.service.IHynfjeService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Hynfje;
import com.ruoyi.framework.web.base.BaseController;
import com.ruoyi.common.page.TableDataInfo;
import com.ruoyi.common.base.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 会员年费金额 信息操作处理
 * 
 * @author ruoyi
 * @date 2019-07-16
 */
@Controller
@RequestMapping("/system/hynfje")
public class HynfjeController extends BaseController
{
    private String prefix = "system/hynfje";
	
	@Autowired
	private IHynfjeService hynfjeService;
	
	@RequiresPermissions("system:hynfje:view")
	@GetMapping()
	public String hynfje()
	{
	    return prefix + "/hynfje";
	}
	
	/**
	 * 查询会员年费金额列表
	 */
	@RequiresPermissions("system:hynfje:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(Hynfje hynfje)
	{
		startPage();
        List<Hynfje> list = hynfjeService.selectHynfjeList(hynfje);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出会员年费金额列表
	 */
	@RequiresPermissions("system:hynfje:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(Hynfje hynfje)
    {
    	List<Hynfje> list = hynfjeService.selectHynfjeList(hynfje);
        ExcelUtil<Hynfje> util = new ExcelUtil<Hynfje>(Hynfje.class);
        return util.exportExcel(list, "hynfje");
    }
	
	/**
	 * 新增会员年费金额
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存会员年费金额
	 */
	@RequiresPermissions("system:hynfje:add")
	@Log(title = "会员年费金额", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(Hynfje hynfje)
	{		
		return toAjax(hynfjeService.insertHynfje(hynfje));
	}

	/**
	 * 修改会员年费金额
	 */
	@GetMapping("/edit/{hynfjeId}")
	public String edit(@PathVariable("hynfjeId") Integer hynfjeId, ModelMap mmap)
	{
		Hynfje hynfje = hynfjeService.selectHynfjeById(hynfjeId);
		mmap.put("hynfje", hynfje);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存会员年费金额
	 */
	@RequiresPermissions("system:hynfje:edit")
	@Log(title = "会员年费金额", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(Hynfje hynfje)
	{		
		return toAjax(hynfjeService.updateHynfje(hynfje));
	}
	
	/**
	 * 删除会员年费金额
	 */
	@RequiresPermissions("system:hynfje:remove")
	@Log(title = "会员年费金额", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(hynfjeService.deleteHynfjeByIds(ids));
	}
	
}
